<?php

class Antz_Form_Components_TimeSelect extends Antz_Form_Component
{
    protected $options = array();

    public function __construct($name, $label, $value=''){
        $this->id = 'sel'.rand();
        $this->name = $name;
        $this->label = $label;
        if($value=='') $value = array('hour'=>date('H'), 'minute'=>date('i'));
        $this->value = $value;
        $this->setLang('en');
    }

    public function setLang($lang='en'){
        $lang = 'en';
        switch($lang){
            case 'en':

            break;
        }
    }

    public function render(){
        global $gCms;
     	$Antz = Antz::registry('Antz');
     	if($this->required) $this->aftertext = '<span class="required"><img src="'.$gCms->config['root_url'].'/modules/Antz/images/required.gif" alt="'.$Antz->Lang('required').'" /></span>'.$this->aftertext;

        // generate the hour options
        $this->hourSel = Antz::newObject('Antz_Form_Components_DateSelect_Select', array($this->name.'Hour', $this->value['hour']));
        for($i=0; $i<=23; $i++){
            $this->hourSel->add($i);
        };
        // generate the minute options
        $this->minSel = Antz::newObject('Antz_Form_Components_DateSelect_Select', array($this->name.'Minute', $this->value['minute']));
        for($i=0; $i<60; $i++){
            $this->minSel->add($i);
        };

        $returnString = $this->hourSel->render().$this->minSel->render();
        if($this->showLabel) $returnString = '<label>'.$this->label.'</label>'.$returnString.'<div class="aftertext">'.$this->aftertext.'</div>';
        if($this->wrap) return $this->wrap($returnString);
        else return $returnString;
    }
}
